package com.demo.project_template.service.impl;

import com.demo.project_template.entity.SysMenu;
import com.demo.project_template.entity.SysRoleMenu;
import com.demo.project_template.mapper.SysMenuMapper;
import com.demo.project_template.mapper.SysRoleMenuMapper;
import com.demo.project_template.service.SysMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.project_template.service.SysRoleMenuService;
import com.demo.project_template.util.CheckEmptyUtil;
import com.demo.project_template.util.JwtUtil;
import com.demo.project_template.vo.request.sys.SysMenuRequestVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 菜单表 服务实现类
 * </p>
 *
 * @author 杨玉龙
 * @since 2024-01-03 20:32:03
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
    @Override
    @Transactional
    public void createSysMenu(SysMenuRequestVO sysMenuRequestVO) {
        SysMenu sysMenu = new SysMenu();
        BeanUtils.copyProperties(sysMenuRequestVO,sysMenu);
        Long userid = JwtUtil.getUserId();
        if (CheckEmptyUtil.isEmpty(sysMenuRequestVO.getId())){
            sysMenu.setCreateBy(userid);
        }
        sysMenu.setUpdateBy(userid);
        saveOrUpdate(sysMenu);
    }
}
